package com.wangjw.jvmDemo;

/**
 * Created by wangjw on 18/8/1.
 */
public class Foo implements AutoCloseable {

    private final String name;

    public Foo(String name) {
        this.name = name;
    }

    @Override
    public void close() throws Exception {
        throw new RuntimeException(name);
    }

    public static void main(String[] args) throws Exception {
        try (Foo foo = new Foo("Foo0");
             Foo foo1 = new Foo("Foo1");
             Foo foo2 = new Foo("Foo2")) {
            throw new RuntimeException("Initial");
        }
    }

    private int tryBlock;
    private int catchBlock;
    private int finallyBlock;
    private int methodExit;

    public void test() {
        try {
            tryBlock = 0;
        } catch (Exception e) {
            catchBlock = 1;
        } finally {
            finallyBlock = 2;
        }
        methodExit = 3;
    }
}
